class AdditionalPermissions < ActiveRecord::Migration
  def self.create_permission(name, role, level)
    Permission.new({'name'=>name, 'role'=>role, 'level'=>level}).save!
  end

  def self.destroy_permission(name, role, level)
    thing = Permission.find_by_name_and_role_and_level(name,role,level)
    thing.destroy
  end

  def self.up
    self.create_permission('create:user','coord','4');
	self.create_permission('view:user','coord','4');
	self.create_permission('edit:user','coord','4');
	self.create_permission('delete:user','coord','4');
	self.create_permission('update:user','coord','4');
	self.create_permission('update:user','lead','4');
	self.create_permission('view:user','lead','4');
	self.create_permission('edit:user','lead','4');

  end

  def self.down
	self.destroy_permission('update:user','lead','4');
	self.destroy_permission('view:user','lead','4');
	self.destroy_permission('edit:user','lead','4');
    self.destroy_permission('destroy:user','coord','4');
	self.destroy_permission('view:user','coord','4');
	self.destroy_permission('edit:user','coord','4');
	self.destroy_permission('delete:user','coord','4');
	self.destroy_permission('update:user','coord','4');
    
  end
end
